package com.leetcode.weekly.contest.no236th;

/**
 * @author 覃国强
 * @date 2021-04-11 10:50
 */
public class A01_数组元素积的符号 {


  public static void main(String[] args) {
    Solution solution = new Solution();
    int[] nums = {-1,1,-1,1,-1};
    int arraySign = solution.arraySign(nums);
    System.out.println(arraySign);
  }



  static
  class Solution {
    public int arraySign(int[] nums) {
      if (nums == null || nums.length == 0) {
        return 0;
      }
      int result = 1;
      for (int num : nums) {
        if (num == 0) {
          return 0;
        } else if (num < 0) {
          result *= -1;
        }
      }
      return result;
    }
  }

}
